package com.gopay.bis.tbank.expay.operation;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import com.gopay.common.util.DateUtils;
import com.gopay.common.domain.bank.tbank.expay.TBankMessageExPayAgreement;
import com.gopay.common.domain.bank.tbank.expay.TBankMessageExPayOrderment;

/**
 * 
 * @ExPayBuildMessage.java
 * @author WangHongFei
 */
public class ExPayBuildMessage {
    /**
     * 快捷支付合约
     * 
     * @param TBankMessageExPayAgreement
     * @return Map
     */
    public Map buildExpayAgree(TBankMessageExPayAgreement tbankExPayAgree) throws Exception{
        String orderDate14 = DateUtils.getLocalFullDateTime14();
        Map tempMap = new ConcurrentHashMap();
        tempMap.put("mercNo", tbankExPayAgree.getMercNo());
        tempMap.put("orderNo", tbankExPayAgree.getOrderId());
        tempMap.put("msgType", tbankExPayAgree.getExPayHashMap().get("msgType"));
        tempMap.put("txnType", tbankExPayAgree.getTxnType());
        tempMap.put("agrmtNo", tbankExPayAgree.getAgrmtNo());
        tempMap.put("orderDate", orderDate14.substring(0, 8));
        tempMap.put("orderTime", orderDate14.substring(8, orderDate14.length()));
        tempMap.put("orderNote", tbankExPayAgree.getOrderNote());
        tempMap.put("signData", tbankExPayAgree.getSignData());
        return tempMap;
    }

    /**
     * 快捷支付订单
     * 
     * @param tBankExpayOrder
     * @return Map
     */
    public Map buildExpayOrder(TBankMessageExPayOrderment tBankExpayOrder) throws Exception{
        String orderDate14 = tBankExpayOrder.getOrderDate();
        Map tempMap = new ConcurrentHashMap();
        tempMap.put("mercNo", tBankExpayOrder.getMercNo());
        tempMap.put("orderNo", tBankExpayOrder.getOrderId());
        tempMap.put("msgType", tBankExpayOrder.getExPayHashMap().get("msgType"));
        tempMap.put("txnType", tBankExpayOrder.getTxnType());
        tempMap.put("agrmtNo", tBankExpayOrder.getAgrmtNo());
        tempMap.put("curCode", tBankExpayOrder.getCurCode());
        tempMap.put("orderAmount", tBankExpayOrder.getAmount().toString());
        tempMap.put("orderDate", orderDate14.substring(0, 8));
        tempMap.put("orderTime", orderDate14.substring(8, orderDate14.length()));
        tempMap.put("orderNote", tBankExpayOrder.getOrderNote());
        tempMap.put("signData", tBankExpayOrder.getSignData());
        return tempMap;
    }

    /**
     * 快捷支付订单查询
     * 
     * @param tBankExpayOrder
     * @return Map
     */
    public Map buildExpayOrderQuery(TBankMessageExPayOrderment tBankExpayOrder) throws Exception{
        Map tempMap = new ConcurrentHashMap();
        tempMap.put("mercNo", tBankExpayOrder.getMercNo());
        tempMap.put("orderNo", tBankExpayOrder.getOrderId());
        tempMap.put("msgType", tBankExpayOrder.getExPayHashMap().get("msgType"));
        tempMap.put("txnType", tBankExpayOrder.getTxnType());
        tempMap.put("signData", tBankExpayOrder.getSignData() == null ? "123" : tBankExpayOrder.getSignData());
        return tempMap;
    }

}
